home *** CD-ROM | disk | FTP | other *** search
/ 10,000 Great Games / 10,000 Great Games.iso / Product / 66 / data1.cab / Source_Files / Src / Init.cpp < prev    next >
C/C++ Source or Header  |  2000-01-16  |  4KB  |  165 lines

  1. #include "stdafx.h"
  2.  
  3. cBMP *backgr, *ambient1, *ambient2;
  4.  
  5. cImage *deaths_icon = 0, *mine_icon = 0, *spread_gun_icon = 0, *jetpack_icon = 0, 
  6.        *rocket_icon = 0, *in_game_pointer = 0, *thumper_icon = 0;
  7.  
  8. char *cmap_gray = 0;
  9.  
  10. cProperties *mine, *bullet, *rocket, *thumper, *water_drop;
  11.  
  12. cRandomList bubble_list, falling_list, pushable_falling_list, crate_list,
  13.             crate_contents_list, hurting_list, inflamable_contents_list, 
  14.             machine_contents_list, parts_list;
  15.  
  16. cSurface *back_surface = 0, *game_surface = 0, *left_surface = 0, 
  17.          *right_surface = 0, *info_surface = 0;
  18.  
  19. static cParse *parsed_properties_file = 0;
  20.  
  21. void init_game_data()
  22. {    
  23.     // Make gravity?
  24.  
  25.     if (!file_exists("Gravity.dat"))
  26.         create_gravity();
  27.     
  28.     // Load gravity
  29.  
  30.     cData::load("Gravity.dat");
  31.  
  32.     // Recreate wave files?
  33.  
  34.     if (!file_exists("Wave.dat"))
  35.         cWAV::create_file();
  36.     
  37.     // Load wave files    
  38.     
  39.     cWAV::load();
  40.  
  41.     // Make colormaps?
  42.     
  43.     if (!file_exists("CMaps.dat"))
  44.         create_colormaps();
  45.     
  46.     // Load colormaps
  47.  
  48.     cData::load("CMaps.dat");
  49.  
  50.     // Recreate bitmaps?
  51.  
  52.     if (!file_exists("Bitmaps.dat"))
  53.         cBMP::create_file();
  54.     
  55.     // Load bitmaps
  56.     
  57.     cBMP::load();
  58.  
  59.     // Create surfaces in order of importance
  60.  
  61.     left_surface = new cLeftSurface();
  62.     right_surface = new cRightSurface();
  63.     
  64.     if (no_parallax)
  65.     {
  66.         game_surface = new cNonParallaxSurface();
  67.         back_surface = game_surface;
  68.     }
  69.     else
  70.     {
  71.         game_surface = new cGameSurface();
  72.         back_surface = new cBackSurface();        
  73.     }    
  74.     
  75.     if (inawin || debug)
  76.         info_surface = new cInfoSurface();
  77.  
  78.     // Some standard things
  79.  
  80.     cmap_gray = (char *)cData::get("GRAY");
  81.         
  82.     backgr = cBMP::get("BACKGR");
  83.     ambient1 = cBMP::get("AMBIENT1");
  84.     ambient2 = cBMP::get("AMBIENT2");
  85.     
  86.     deaths_icon = new cImage(cBMP::get("ICON_DEATHS"));
  87.     mine_icon = new cImage(cBMP::get("ICON_MINE"));
  88.     spread_gun_icon = new cImage(cBMP::get("ICON_SPREAD_GUN"));
  89.     jetpack_icon = new cImage(cBMP::get("ICON_JETPACK"));
  90.     rocket_icon = new cImage(cBMP::get("ICON_ROCKET"));
  91.     thumper_icon = new cImage(cBMP::get("ICON_THUMPER"));
  92.  
  93.     in_game_pointer = new cImage(cBMP::get("IN_GAME_POINTER"));
  94.     in_game_pointer->origin_center();
  95.     
  96.     // Parse properties file
  97.     
  98.     cParse::parse_file("WATER.BDS", &parsed_properties_file);
  99.     
  100.     // Create property objects
  101.     
  102.     cProperties::create_all(parsed_properties_file);
  103.     
  104.     // Define standard properties
  105.     
  106.     mine = cProperties::find_w_error("MINE", "MINE");
  107.     bullet = cProperties::find_w_error("BULLET", "BULLET");
  108.     rocket = cProperties::find_w_error("ROCKET", "ROCKET");
  109.     thumper = cProperties::find_w_error("THUMPER", "THUMPER");
  110.     water_drop = cProperties::find_w_error("FALLING SCENERY", "WATER DROP");
  111.     
  112.     // Define random lists
  113.     
  114.     bubble_list.add_to_list("BUBBLE");
  115.     crate_contents_list.add_to_list("FALLING", "FLARE");
  116.     inflamable_contents_list.add_to_list("HURTING");
  117.     machine_contents_list.add_to_list("ROLLING");
  118.     parts_list.add_to_list("PARTS");
  119. }
  120.  
  121. void deinit_game_data()
  122.     // Remove parsed properties file
  123.     
  124.     parsed_properties_file->delete_list();
  125.     
  126.     // Remove properties objects
  127.     
  128.     props->delete_list();
  129.     
  130.     // Remove random lists
  131.     
  132.     bubble_list.delete_list();
  133.     crate_contents_list.delete_list();
  134.     inflamable_contents_list.delete_list();
  135.     machine_contents_list.delete_list();
  136.     parts_list.delete_list();
  137.  
  138.     // Delete surfaces
  139.     
  140.     safe_delete(&left_surface);
  141.     safe_delete(&right_surface);
  142.     safe_delete(&game_surface);
  143.     safe_delete(&info_surface);
  144.  
  145.     if (!no_parallax)
  146.         safe_delete(&back_surface);
  147.  
  148.     // Delete standard allocated images
  149.  
  150.     safe_delete(&deaths_icon);
  151.     safe_delete(&mine_icon);
  152.     safe_delete(&spread_gun_icon);
  153.     safe_delete(&jetpack_icon);
  154.     safe_delete(&rocket_icon);
  155.     safe_delete(&thumper_icon);
  156.     safe_delete(&in_game_pointer);
  157.  
  158.     // Clear memory from bitmaps etc.
  159.  
  160.     wave->delete_list();
  161.     bitmaps->delete_list();
  162.     data->delete_list();
  163. }
  164.